<template>
	<view>
		<Home v-show="current == 0" />
		<My v-show="current == 1" :info="info"/>
		<u-tabbar v-model="current" :list="list" ></u-tabbar>
	</view>
</template>
<script>
	import Home from './Home.vue';
	import My from './My.vue'
	import {
		storeHome
	} from '@/api/storeAdmin.js';
	import storage from '@/utils/storage.js';
	export default {
		components: {
			Home,
			My
		},
		onReachBottom(){
		  // 给子级监听触底加载
		  uni.$emit('onReachBottomtrue',true)

		},
		
		onLoad(option) {
			if(option.current){
				this.current = option.current
			}
		},
		
		onShow() {
			storeHome({
				id: storage.getUserInfo().storeId
			}).then(res => {
				if (res.code == '000000') {
					this.info = res.data;
				}
			})
			
			uni.$emit('onShowTrue', true)
		},
		
		
		
		
		destroyed() {
			uni.$off('onShowTrue')
			uni.$off('onReachBottomtrue')
		},
		
		data() {
			return {
				list: [{
						iconPath: "/static/businessImg/home.png",
						selectedIconPath: "/static/businessImg/home_selected.png",
						text: '首页',
					},
					{
						iconPath: "/static/businessImg/my.png",
						selectedIconPath: "/static/businessImg/my_selected.png",
						text: '我的',
					},
				],
				current: 0,
				info: {}
			}
		},
	}
</script>

